package com.example.service;

import com.example.entity.Activity;
import com.example.mapper.ActivityMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 功能：活动服务
 * 日期：2024/1/31 20:51
 */
@Service
public class ActivityService {

    @Resource
    private ActivityMapper activityMapper;
    public void add(Activity activity) {
        activityMapper.add(activity);
    }

    public void deleteById(Integer id) {
        activityMapper.deleteById(id);
    }

    public void deleteBatch(List<Integer> ids) {
        for (Integer id: ids){
            activityMapper.deleteById(id);
        }
    }

    public void updateById(Activity activity) {
        activityMapper.updateById(activity);
    }

    public Activity selectById(Integer id) {
        return activityMapper.selectById(id);
    }

    public List<Activity> selectAll(Activity activity) {
        return activityMapper.selectAll(activity);
    }

    public PageInfo<Activity> selectPage(Activity activity, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Activity> list = activityMapper.selectAll(activity);
        return PageInfo.of(list);
    }
}